FROM golang:1.12

# build lua jit
COPY ./LuaJIT-2.1.0-beta3.tar.gz /tmp/ 
RUN cd /tmp/ && tar xzvf /tmp/LuaJIT-2.1.0-beta3.tar.gz  && cd LuaJIT-2.1.0-beta3 && make \
&&  make install PREFIX=/usr/local/luajit && rm -rf /tmp/LuaJIT-2.1.0-beta3 && rm /tmp/LuaJIT-2.1.0-beta3.tar.gz

# env
ENV CGO_CFlAGS=' -std=gnu99 -I/usr/local/luajit/include/luajit-2.1'
ENV CGO_LDFLAGS=' -L/usr/local/luajit/lib -lluajit-5.1 -lm -ldl'
ENV LD_LIBRARY_PATH='/usr/local/luajit/lib'
WORKDIR /
COPY ./install.sh .
COPY ./config.dev.json .
RUN chmod +x ./install.sh
VOLUME ["/go"]
EXPOSE 9004
CMD ["./install.sh"]

# build:
# docker build -t mygo
# run:
# docker run -it --rm --name demo mygo